home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 September / Chip_2002-09_cd1.bin / sharewar / slunec / app / httrack.exe / {app} / src_win / WinHTTrack / Infoend.cpp < prev    next >
C/C++ Source or Header  |  2002-05-16  |  7KB  |  298 lines

  1. // infoend.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Shell.h"
  6. #include "infoend.h"
  7. #include "iplog.h"
  8. #include "NewProj.h"
  9.  
  10. extern CNewProj* dialog0;
  11. extern "C" {
  12.   HTS_INLINE int fspc(FILE* fp,char* type);
  13. }
  14.  
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. extern HICON httrack_icon;
  21.  
  22. #include "winhttrack.h"
  23. extern CWinHTTrackApp* this_app;
  24.  
  25. #include "inprogress.h"
  26. extern Cinprogress* inprogress;
  27.  
  28. /* Externe C */
  29. extern "C" {
  30.   #include "htslib.h"
  31. }
  32.  
  33. ///extern "C" int fexist(char*);
  34. //extern char* fconcat(char*,char*);
  35.  
  36. // Helper
  37. extern LaunchHelp* HtsHelper;
  38.  
  39. /* Main splitter frame */
  40. #include "DialogContainer.h"
  41. #include "splitter.h"
  42. extern CSplitterFrame* this_CSplitterFrame;
  43.  
  44. /* Main WizTab frame */
  45. #include "WizTab.h"
  46. extern CWizTab* this_CWizTab;
  47. extern CWizTab* this_intCWizTab2;
  48.  
  49. /* Objet lui mΩme */
  50. Cinfoend* this_Cinfoend=NULL;
  51.  
  52. /////////////////////////////////////////////////////////////////////////////
  53. // Cinfoend dialog
  54.  
  55. IMPLEMENT_DYNCREATE(Cinfoend, CPropertyPage)
  56.  
  57. Cinfoend::Cinfoend()
  58.     : CPropertyPage(Cinfoend::IDD)
  59. {
  60.   this_Cinfoend=this;
  61.     //{{AFX_DATA_INIT(Cinfoend)
  62.     //}}AFX_DATA_INIT
  63. }
  64.  
  65. Cinfoend::~Cinfoend() {
  66.   this_Cinfoend=NULL;
  67. }
  68.  
  69. void Cinfoend::DoDataExchange(CDataExchange* pDX)
  70. {
  71.     CPropertyPage::DoDataExchange(pDX);
  72.     //{{AFX_DATA_MAP(Cinfoend)
  73.     //}}AFX_DATA_MAP
  74. }
  75.  
  76.  
  77. BEGIN_MESSAGE_MAP(Cinfoend, CPropertyPage)
  78.     //{{AFX_MSG_MAP(Cinfoend)
  79.     ON_BN_CLICKED(IDlog, Onlog)
  80.     ON_BN_CLICKED(IDbrowse, Onbrowse)
  81.     ON_WM_HELPINFO()
  82.     ON_WM_TIMER()
  83.     ON_WM_DESTROY()
  84.     //}}AFX_MSG_MAP
  85.   ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  86.   ON_COMMAND(ID_HELP_FINDER,OnHelpInfo2)
  87.   ON_COMMAND(ID_HELP,OnHelpInfo2)
  88.     ON_COMMAND(ID_DEFAULT_HELP,OnHelpInfo2)
  89. END_MESSAGE_MAP()
  90.  
  91. /////////////////////////////////////////////////////////////////////////////
  92. // Cinfoend message handlers
  93.  
  94. BOOL Cinfoend::OnInitDialog() 
  95. {
  96.   UpdateData(false);      // force to call DoDataExchange
  97.  
  98.     //CPropertyPage::OnInitDialog();
  99.     
  100.   SetIcon(httrack_icon,false);
  101.   SetIcon(httrack_icon,true);  
  102.   EnableToolTips(true);     // TOOL TIPS
  103.   SetForegroundWindow();   // yop en premier plan!
  104.  
  105.   // Patcher l'interface pour les Franτais ;-)
  106.   if (LANG_T(-1)) {    // Patcher en franτais
  107.     //SetDlgItemText(,"");
  108.     //SetWindowText(LANG(LANG_D6) /*"Fin du miroir"*/);
  109.     SetDlgItemText(IDlog,LANG(LANG_D7) /*"Voir fichier d'audit"*/);
  110.     SetDlgItemText(IDbrowse,LANG(LANG_D8) /*"Lancer Web"*/);
  111.     this_CWizTab->SetDlgItemText(IDCANCEL,LANG_QUIT);
  112.     //SetDlgItemText(IDC_NewProject,LANG_D9);
  113.     //SetDlgItemText(IDOK,LANG_OK);
  114.   }
  115.  
  116.   int error = HTS_STAT.stat_errors;
  117.   if (error) {
  118.     SetDlgItemText(IDlog,LANG_O14);
  119.     tm=SetTimer(WM_TIMER,250,NULL);
  120.   }
  121.  
  122.     return TRUE;
  123. }
  124.  
  125. void Cinfoend::Onlog() 
  126. {
  127.   char pathlog[HTS_URLMAXSIZE*2];
  128.   strcpy(pathlog,dialog0->GetPath());
  129.   Ciplog form;
  130.   if (strlen(pathlog)>0)
  131.   if ((pathlog[strlen(pathlog)-1]!='/') && (pathlog[strlen(pathlog)-1]!='\\'))
  132.     strcat(pathlog,"/");
  133.   // fichier log existe ou on est tΘlΘcommandΘ par un !
  134.   if ( (fexist(fconcat(pathlog,"hts-err.txt"))) || (fexist(fconcat(pathlog,"hts-log.txt"))) ) {
  135.     strcpy(form.pathlog,pathlog);
  136.     form.DoModal();
  137.   } else {
  138.     char s[HTS_URLMAXSIZE*2];
  139.     sprintf(s,LANG(LANG_D1 /*"No log files in %s!"*/ ),pathlog);
  140.     AfxMessageBox(s,MB_OK+MB_ICONEXCLAMATION);
  141.   }
  142. }
  143.  
  144. void Cinfoend::Onbrowse() 
  145. {
  146.   char pathlog[HTS_URLMAXSIZE*2];
  147.   strcpy(pathlog,dialog0->GetPath());
  148.   if (strlen(pathlog)==0)
  149.     strcpy(pathlog,dialog0->GetPath());
  150.   Ciplog form;
  151.   if (strlen(pathlog)>0)
  152.   if ((pathlog[strlen(pathlog)-1]!='/') && (pathlog[strlen(pathlog)-1]!='\\'))
  153.     strcat(pathlog,"\\");
  154.   if ( fexist(fconcat(pathlog,"index.html")) ) {
  155.     ShellExecute(this->m_hWnd,"open",fconcat(pathlog,"index.html"),"","",SW_RESTORE);    
  156.   } else {
  157.     char s[HTS_URLMAXSIZE*2];
  158.     sprintf(s,LANG(LANG_D2 /*"No index.html file in %s!"*/ ),pathlog);
  159.     AfxMessageBox(s,MB_OK+MB_ICONEXCLAMATION);
  160.   }
  161. }
  162.  
  163.  
  164.  
  165. // ------------------------------------------------------------
  166. // TOOL TIPS
  167. //
  168. // ajouter dans le .cpp:
  169. // remplacer les deux Wid1:: par le nom de la classe::
  170. // dans la message map, ajouter
  171. // ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  172. // dans initdialog ajouter
  173. // EnableToolTips(true);     // TOOL TIPS
  174. //
  175. // ajouter dans le .h:
  176. // char* GetTip(int id);
  177. // et en generated message map
  178. // afx_msg BOOL OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
  179. BOOL Cinfoend::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
  180. {
  181.   TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
  182.   UINT nID =pNMHDR->idFrom;
  183.   if (pTTT->uFlags & TTF_IDISHWND)
  184.   {
  185.     // idFrom is actually the HWND of the tool
  186.     nID = ::GetDlgCtrlID((HWND)nID);
  187.     if(nID)
  188.     {
  189.       char* st=GetTip(nID);
  190.       if (st != "") {
  191.         pTTT->lpszText = st;
  192.         pTTT->hinst = AfxGetResourceHandle();
  193.         return(TRUE);
  194.       }
  195.     }
  196.   }
  197.   return(FALSE);
  198. }
  199. char* Cinfoend::GetTip(int ID)
  200. {
  201.   switch(ID) {
  202.     case IDOK:     return LANG(LANG_D3 /*"Click to quit WinHTTrack"*/ ); break;
  203.     case IDlog:    return LANG(LANG_D4 /*"View log files"*/ ); break;
  204.     case IDbrowse: return LANG(LANG_D5 /*"Browse html start page"*/ ); break;
  205.     //case : return ""; break;
  206.   }
  207.   return "";
  208. }
  209. // TOOL TIPS
  210. // ------------------------------------------------------------
  211.  
  212.  
  213.  
  214. // Appel aide
  215. BOOL Cinfoend::OnHelpInfo2() {
  216.   return OnHelpInfo(NULL);
  217. }
  218.  
  219. BOOL Cinfoend::OnHelpInfo(HELPINFO* dummy) 
  220. {
  221.   //return CPropertyPage::OnHelpInfo(pHelpInfo);
  222.   HtsHelper->Help("step5.html");
  223.   return true;
  224.   //AfxGetApp()->WinHelp(0,HELP_FINDER);    // Index du fichier Hlp
  225.   //return true;
  226. }
  227.  
  228. void Cinfoend::OnBye() 
  229. {
  230.   //this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));    
  231.   // // // this_CWizTab2->DestroyWindow(); // crash!!
  232.  
  233.   //delete this_intCWizTab2->m_tabprogress;  // agh..
  234.   //this_intCWizTab2->m_tabprogress=NULL; inprogress=NULL; this_app->m_tabprogress=NULL;    // re agh..
  235.  
  236.   /* tout effacer */
  237.   //##while(this_intCWizTab2->GetPageCount()>0)
  238.   //##  this_intCWizTab2->RemovePage(0);
  239.   
  240.   //##this_intCWizTab2=NULL;
  241.   AfxGetMainWnd()->SendMessage(WM_COMMAND,wm_ViewRestart,0);
  242. }
  243.  
  244. BOOL Cinfoend::OnQueryCancel( ) {
  245.   //if (AfxMessageBox(LANG(LANG_J1),MB_OKCANCEL)==IDOK) {
  246.   /* Envoyer un WM_CLOSE α notre fenΩtre principale */
  247.   AfxGetMainWnd()->SendMessage(WM_CLOSE,0,0);
  248.   //}
  249.   return FALSE;
  250. }
  251.  
  252. BOOL Cinfoend::OnSetActive( ) {
  253.   // dΘtruire ICI sinon crash!!!!
  254.   WHTT_LOCATION("Infoend");
  255.   if (this_intCWizTab2) {
  256.     this_intCWizTab2->DestroyWindow();
  257.     delete this_intCWizTab2;
  258.     this_intCWizTab2=NULL;
  259.   }
  260.  
  261.   this_CWizTab->SetWizardButtons(PSWIZB_FINISH);
  262.   this_app->GetMainWnd()->SetWindowText(LANG_F18b);
  263.   this_CWizTab->SetDlgItemText(IDCANCEL,LANG_QUIT);
  264.   return 1;
  265. }
  266.  
  267. BOOL Cinfoend::OnWizardFinish( ) {
  268.   OnBye();
  269.     return 0;
  270. }
  271.  
  272.  
  273. void Cinfoend::OnTimer(UINT nIDEvent) 
  274. {
  275.   static wflag=FALSE;
  276.  
  277.   wflag=!wflag;
  278.  
  279.   CWnd* wnd=GetDlgItem(IDlog);
  280.   if (wnd) {
  281.     CString st="";
  282.     if (wflag)
  283.       st=LANG_O14;
  284.     SetDlgItemText(IDlog,st);
  285.   }
  286.   
  287.     CPropertyPage::OnTimer(nIDEvent);
  288. }
  289.  
  290. void Cinfoend::OnDestroy() 
  291. {
  292.   if (tm!=0) {
  293.     KillTimer(tm); 
  294.     tm=-1; 
  295.   }
  296.     CPropertyPage::OnDestroy();
  297. }
  298.